package com.chhuang.ewcrm.api;

import com.chhuang.ewcrm.ctrl.InitController;
import io.reactivex.Flowable;
import io.reactivex.FlowableTransformer;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;

/**
 * @author chhuang
 * @create 2020-10-23-15:16
 */
public class ServiceRxSchedulers {
    /**
     *
     * @param <T>
     * @return
     */
    public static <T> FlowableTransformer<T, T> compose() {
        return compose(false);
    }

    /**
     * 显示等待弹出框的加载，要对应使用关闭弹出框的ServiceSubscriber构造方法
     * @param isShowLoadDialog
     * @param <T>
     * @return
     */
    public static <T> FlowableTransformer<T, T> compose(final boolean isShowLoadDialog) {
        return upstream -> upstream.subscribeOn(Schedulers.io())
                .doOnSubscribe((subscription)-> {
                    if(isShowLoadDialog){//显示加载中。。。

                    }else {

                    }
                }).observeOn(Schedulers.newThread());
    }
}
